package com.acme.bankapp.service.bank;

import java.io.IOException;

import com.acme.bankapp.domain.bank.Account;
import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.exceptions.ClientExistsException;

public class BankService {
	public static void addClient (Bank bank, Client client) throws ClientExistsException {
		bank.addClient(client);
	}
	
	public static void printMaximumAmountToWithdraw(Bank bank) {
		for (Client cur: bank.getClients()) {
			System.out.println(cur.getClientSalutation());
			for (Account acc: cur.getAccounts()) {
				System.out.println(acc.maxAmountToWithdraw());
			}
		}
	}
	
	public static void saveBank (Bank bank) throws IOException {
		bank.writeStringBuffer(bank);
	}
	
	public static Bank readBank() throws ClassNotFoundException, IOException {
		return Bank.readStringBuffer();
	}

}
